<!DOCTYPE html>
<html lang="en-us">
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    
<meta charset="UTF-8">
<title>Index-Time Search-as-You-Type | Elasticsearch: The Definitive Guide [2.x] | Elastic</title>
<link rel="home" href="index.html" title="Elasticsearch: The Definitive Guide [2.x]">
<link rel="up" href="partial-matching.html" title="Partial Matching">
<link rel="prev" href="_ngrams_for_partial_matching.html" title="Ngrams for Partial Matching">
<link rel="next" href="ngrams-compound-words.html" title="Ngrams for Compound Words">
<meta name="DC.type" content="Learn/Docs/Legacy/Elasticsearch/Definitive Guide/2.x">
<meta name="DC.subject" content="Elasticsearch">
<meta name="DC.identifier" content="2.x">
<meta name="robots" content="noindex,nofollow">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.optimizely.com/js/18132920325.js"></script>
    <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
    <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
    <link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
    <link rel="manifest" href="/manifest.json">
    <meta name="apple-mobile-web-app-title" content="Elastic">
    <meta name="application-name" content="Elastic">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="/mstile-144x144.png">
    <meta name="theme-color" content="#ffffff">
    <meta name="naver-site-verification" content="936882c1853b701b3cef3721758d80535413dbfd">
    <meta name="yandex-verification" content="d8a47e95d0972434">
    <meta name="localized" content="true">
    <meta name="st:robots" content="follow,index">
    <meta property="og:image" content="https://www.elastic.co/static/images/elastic-logo-200.png">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon-precomposed" sizes="64x64" href="/favicon_64x64_16bit.png">
    <link rel="apple-touch-icon-precomposed" sizes="32x32" href="/favicon_32x32.png">
    <link rel="apple-touch-icon-precomposed" sizes="16x16" href="/favicon_16x16.png">
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/guide/static/styles.css">
  </head>

  <!--© 2015-2021 Elasticsearch B.V. Copying, publishing and/or distributing without written permission is strictly prohibited.-->

  <body>
    <!-- Google Tag Manager -->
    <script>dataLayer = [];</script><noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-58RLH5" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-58RLH5');</script>
    <!-- End Google Tag Manager -->

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-12395217-16"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'UA-12395217-16');
    </script>

    <!--BEGIN QUALTRICS WEBSITE FEEDBACK SNIPPET-->
    <script type="text/javascript">
      (function(){var g=function(e,h,f,g){
      this.get=function(a){for(var a=a+"=",c=document.cookie.split(";"),b=0,e=c.length;b<e;b++){for(var d=c[b];" "==d.charAt(0);)d=d.substring(1,d.length);if(0==d.indexOf(a))return d.substring(a.length,d.length)}return null};
      this.set=function(a,c){var b="",b=new Date;b.setTime(b.getTime()+6048E5);b="; expires="+b.toGMTString();document.cookie=a+"="+c+b+"; path=/; "};
      this.check=function(){var a=this.get(f);if(a)a=a.split(":");else if(100!=e)"v"==h&&(e=Math.random()>=e/100?0:100),a=[h,e,0],this.set(f,a.join(":"));else return!0;var c=a[1];if(100==c)return!0;switch(a[0]){case "v":return!1;case "r":return c=a[2]%Math.floor(100/c),a[2]++,this.set(f,a.join(":")),!c}return!0};
      this.go=function(){if(this.check()){var a=document.createElement("script");a.type="text/javascript";a.src=g;document.body&&document.body.appendChild(a)}};
      this.start=function(){var a=this;window.addEventListener?window.addEventListener("load",function(){a.go()},!1):window.attachEvent&&window.attachEvent("onload",function(){a.go()})}};
      try{(new g(100,"r","QSI_S_ZN_emkP0oSe9Qrn7kF","https://znemkp0ose9qrn7kf-elastic.siteintercept.qualtrics.com/WRSiteInterceptEngine/?Q_ZID=ZN_emkP0oSe9Qrn7kF")).start()}catch(i){}})();
    </script><div id="ZN_emkP0oSe9Qrn7kF"><!--DO NOT REMOVE-CONTENTS PLACED HERE--></div>
    <!--END WEBSITE FEEDBACK SNIPPET-->

    <div id="elastic-nav" style="display:none;"></div>
    <script src="https://www.elastic.co/elastic-nav.js"></script>

    <!-- Subnav -->
    <div>
      <div>
        <div class="tertiary-nav d-none d-md-block">
          <div class="container">
            <div class="p-t-b-15 d-flex justify-content-between nav-container">
              <div class="breadcrum-wrapper"><span><a href="/guide/" style="font-size: 14px; font-weight: 600; color: #000;">Docs</a></span></div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="main-container">
      <section id="content">
        <div class="content-wrapper">

          <section id="guide" lang="en">
            <div class="container">
              <div class="row">
                <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                  <!-- start body -->
                  <div class="page_header">
<p>
  <strong>WARNING</strong>: The 2.x versions of Elasticsearch have passed their
  <a href="https://www.elastic.co/support/eol">EOL dates</a>. If you are running
  a 2.x version, we strongly advise you to upgrade.
</p>
<p>
  This documentation is no longer maintained and may be removed. For the latest
  information, see the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html">current
  Elasticsearch documentation</a>.
</p>
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch: The Definitive Guide [2.x]</a></span>
»
<span class="breadcrumb-link"><a href="search-in-depth.html">Search in Depth</a></span>
»
<span class="breadcrumb-link"><a href="partial-matching.html">Partial Matching</a></span>
»
<span class="breadcrumb-node">Index-Time Search-as-You-Type</span>
</div>
<div class="navheader">
<span class="prev">
<a href="_ngrams_for_partial_matching.html">« Ngrams for Partial Matching</a>
</span>
<span class="next">
<a href="ngrams-compound-words.html">Ngrams for Compound Words »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="_index_time_search_as_you_type"></a>Index-Time Search-as-You-Type<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch-definitive-guide/edit/2.x/130_Partial_Matching/35_Search_as_you_type.asciidoc">edit</a>
</h2>
</div></div></div>
<p>The first step to setting up index-time search-as-you-type is to define our
analysis chain, which we discussed  in <a class="xref" href="configuring-analyzers.html" title="Configuring Analyzers">Configuring Analyzers</a>, but we will
go over the steps again here.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_preparing_the_index"></a>Preparing the Index<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch-definitive-guide/edit/2.x/130_Partial_Matching/35_Search_as_you_type.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The first step is to configure a custom <code class="literal">edge_ngram</code> token filter, which we
will call the <code class="literal">autocomplete_filter</code>:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{
    "filter": {
        "autocomplete_filter": {
            "type":     "edge_ngram",
            "min_gram": 1,
            "max_gram": 20
        }
    }
}</pre>
</div>
<p>This configuration says that, for any term that this token filter receives,
it should produce an n-gram anchored to the start of the word of minimum
length 1 and maximum length 20.</p>
<p>Then we need to use this token filter in a custom analyzer, which we will call
the <code class="literal">autocomplete</code> analyzer:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{
    "analyzer": {
        "autocomplete": {
            "type":      "custom",
            "tokenizer": "standard",
            "filter": [
                "lowercase",
                "autocomplete_filter" <a id="CO95-1"></a><i class="conum" data-value="1"></i>
            ]
        }
    }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO95-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Our custom edge-ngram token filter</p>
</td>
</tr>
</table>
</div>
<p>This analyzer will tokenize a string into individual terms by using the
<code class="literal">standard</code> tokenizer, lowercase each term, and then produce edge n-grams of each
term, thanks to our <code class="literal">autocomplete_filter</code>.</p>
<p>The full request to create the index and instantiate the token filter and
analyzer looks like this:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">PUT /my_index
{
    "settings": {
        "number_of_shards": 1, <a id="CO96-1"></a><i class="conum" data-value="1"></i>
        "analysis": {
            "filter": {
                "autocomplete_filter": { <a id="CO96-2"></a><i class="conum" data-value="2"></i>
                    "type":     "edge_ngram",
                    "min_gram": 1,
                    "max_gram": 20
                }
            },
            "analyzer": {
                "autocomplete": {
                    "type":      "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "autocomplete_filter" <a id="CO96-3"></a><i class="conum" data-value="3"></i>
                    ]
                }
            }
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO96-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>See <a class="xref" href="relevance-is-broken.html" title="Relevance Is Broken!">Relevance Is Broken!</a>.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO96-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>First we define our custom token filter.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO96-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>Then we use it in an analyzer.</p>
</td>
</tr>
</table>
</div>
<p>You can test this new analyzer to make sure it is behaving correctly by using
the <code class="literal">analyze</code> API:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">GET /my_index/_analyze
{
  "analyzer": "autocomplete",
  "text": "quick brown"
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<p>The results show us that the analyzer is working correctly. It returns these
terms:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">q</code>
</li>
<li class="listitem">
<code class="literal">qu</code>
</li>
<li class="listitem">
<code class="literal">qui</code>
</li>
<li class="listitem">
<code class="literal">quic</code>
</li>
<li class="listitem">
<code class="literal">quick</code>
</li>
<li class="listitem">
<code class="literal">b</code>
</li>
<li class="listitem">
<code class="literal">br</code>
</li>
<li class="listitem">
<code class="literal">bro</code>
</li>
<li class="listitem">
<code class="literal">brow</code>
</li>
<li class="listitem">
<code class="literal">brown</code>
</li>
</ul>
</div>
<p>To use the analyzer, we need to apply it to a field, which we can do
with the <code class="literal">update-mapping</code> API:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">PUT /my_index/_mapping/my_type
{
    "my_type": {
        "properties": {
            "name": {
                "type":     "string",
                "analyzer": "autocomplete"
            }
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<p>Now, we can index some test documents:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">POST /my_index/my_type/_bulk
{ "index": { "_id": 1            }}
{ "name": "Brown foxes"    }
{ "index": { "_id": 2            }}
{ "name": "Yellow furballs" }</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_querying_the_field"></a>Querying the Field<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch-definitive-guide/edit/2.x/130_Partial_Matching/35_Search_as_you_type.asciidoc">edit</a>
</h3>
</div></div></div>
<p>If you test out a query for “brown fo” by using a simple <code class="literal">match</code> query</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">GET /my_index/my_type/_search
{
    "query": {
        "match": {
            "name": "brown fo"
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<p>you will see that <em>both</em> documents match, even though the <code class="literal">Yellow furballs</code>
doc contains neither <code class="literal">brown</code> nor <code class="literal">fo</code>:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{

  "hits": [
     {
        "_id": "1",
        "_score": 1.5753809,
        "_source": {
           "name": "Brown foxes"
        }
     },
     {
        "_id": "2",
        "_score": 0.012520773,
        "_source": {
           "name": "Yellow furballs"
        }
     }
  ]
}</pre>
</div>
<p>As always, the <code class="literal">validate-query</code> API shines some light:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">GET /my_index/my_type/_validate/query?explain
{
    "query": {
        "match": {
            "name": "brown fo"
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<p>The <code class="literal">explanation</code> shows us that the query is looking for edge n-grams of every
word in the query string:</p>
<pre class="literallayout">name:b name:br name:bro name:brow name:brown name:f name:fo</pre>

<p>The <code class="literal">name:f</code> condition is satisfied by the second document because
<code class="literal">furballs</code> has been indexed as <code class="literal">f</code>, <code class="literal">fu</code>, <code class="literal">fur</code>, and so forth.  In retrospect, this
is not surprising.  The same <code class="literal">autocomplete</code> analyzer is being applied both at
index time and at search time, which in most situations is the right thing to
do. This is one of the few occasions when it makes sense to break this rule.</p>
<p>We want to ensure that our inverted index contains edge n-grams of every word,
but we want to match only the full words that the user has entered (<code class="literal">brown</code> and <code class="literal">fo</code>).  We can do this by using the <code class="literal">autocomplete</code> analyzer at
index time and the <code class="literal">standard</code> analyzer at search time.  One way to change the
search analyzer is just to specify it in the query:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">GET /my_index/my_type/_search
{
    "query": {
        "match": {
            "name": {
                "query":    "brown fo",
                "analyzer": "standard" <a id="CO97-1"></a><i class="conum" data-value="1"></i>
            }
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO97-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>This overrides the <code class="literal">analyzer</code> setting on the <code class="literal">name</code> field.</p>
</td>
</tr>
</table>
</div>
<p>Alternatively, we can specify the <code class="literal">analyzer</code> and <code class="literal">search_analyzer</code> in
the mapping for the <code class="literal">name</code> field itself. Because we want to change only the
<code class="literal">search_analyzer</code>, we can update the existing mapping without having to
reindex our data:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">PUT /my_index/my_type/_mapping
{
    "my_type": {
        "properties": {
            "name": {
                "type":            "string",
                "analyzer":  "autocomplete", <a id="CO98-1"></a><i class="conum" data-value="1"></i>
                "search_analyzer": "standard" <a id="CO98-2"></a><i class="conum" data-value="2"></i>
            }
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Search_as_you_type.json"></div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO98-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Use the <code class="literal">autocomplete</code> analyzer at index time to produce edge n-grams of
every term.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO98-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>Use the <code class="literal">standard</code> analyzer at search time to search only on the terms
that the user has entered.</p>
</td>
</tr>
</table>
</div>
<p>If we were to repeat the <code class="literal">validate-query</code> request, it would now give us this
explanation:</p>
<pre class="literallayout">name:brown name:fo</pre>

<p>Repeating our query correctly returns just the <code class="literal">Brown foxes</code>
document.</p>
<p>Because most of the work has been done at index time, all this query needs to
do is to look up the two terms <code class="literal">brown</code> and <code class="literal">fo</code>, which is much more efficient
than the <code class="literal">match_phrase_prefix</code> approach of having to find all terms beginning
with <code class="literal">fo</code>.</p>
<div class="sidebar">
<div class="titlepage"><div><div>
<p class="title"><strong>Completion Suggester</strong></p>
</div></div></div>
<p>Using edge n-grams for search-as-you-type is easy to set up, flexible, and
fast.  However, sometimes it is not fast enough.  Latency matters, especially
when you are trying to provide instant feedback.  Sometimes the fastest way of
searching is not to search at all.</p>
<p>The <a href="/guide/en/elasticsearch/reference/2.4/search-suggesters-completion.html" class="ulink" target="_top">completion suggester</a> in
Elasticsearch takes a completely different approach.  You feed it a list
of all possible completions, and it builds them into a <em>finite state
transducer</em>, an optimized data structure that resembles a big graph.  To
search for suggestions, Elasticsearch starts at the beginning of the graph and
moves character by character along the matching path. Once it has run out of
user input, it looks at all possible endings of the  current path to produce a
list of suggestions.</p>
<p>This data structure lives in memory and makes prefix lookups extremely fast,
much faster than any term-based query could be.  It is an excellent match for
autocompletion of names and brands, whose words are usually organized in a
common order: “Johnny Rotten” rather than “Rotten Johnny.”</p>
<p>When word order is less predictable, edge n-grams can be a better solution
than the completion suggester.  This particular cat may be skinned in myriad
ways.</p>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_edge_n_grams_and_postcodes"></a>Edge n-grams and Postcodes<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch-definitive-guide/edit/2.x/130_Partial_Matching/35_Search_as_you_type.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The edge n-gram approach can also be used for structured data, such as the
postcodes example from <a class="xref" href="prefix-query.html" title="prefix Query">earlier in this chapter</a>.  Of course,
the <code class="literal">postcode</code> field would need to be <code class="literal">analyzed</code> instead of <code class="literal">not_analyzed</code>, but
you could use the <code class="literal">keyword</code> tokenizer to treat the postcodes as if they were
<code class="literal">not_analyzed</code>.</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>The <code class="literal">keyword</code> tokenizer is the no-operation tokenizer, the tokenizer that does
nothing.  Whatever string it receives as input, it emits exactly the same
string as a single token.  It can therefore be used for values that we would
normally treat as <code class="literal">not_analyzed</code> but that require some other analysis
transformation such as lowercasing.</p>
</div>
</div>
<p>This example uses the <code class="literal">keyword</code> tokenizer to convert the postcode string into a token stream, so that we can use the edge n-gram token filter:</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">{
    "analysis": {
        "filter": {
            "postcode_filter": {
                "type":     "edge_ngram",
                "min_gram": 1,
                "max_gram": 8
            }
        },
        "analyzer": {
            "postcode_index": { <a id="CO99-1"></a><i class="conum" data-value="1"></i>
                "tokenizer": "keyword",
                "filter":    [ "postcode_filter" ]
            },
            "postcode_search": { <a id="CO99-2"></a><i class="conum" data-value="2"></i>
                "tokenizer": "keyword"
            }
        }
    }
}</pre>
</div>
<div class="sense_widget" data-snippet="snippets/130_Partial_Matching/35_Postcodes.json"></div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO99-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The <code class="literal">postcode_index</code> analyzer would use the <code class="literal">postcode_filter</code>
to turn postcodes into edge n-grams.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO99-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The <code class="literal">postcode_search</code> analyzer would treat search terms as
if they were <code class="literal">not_analyzed</code>.</p>
</td>
</tr>
</table>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="_ngrams_for_partial_matching.html">« Ngrams for Partial Matching</a>
</span>
<span class="next">
<a href="ngrams-compound-words.html">Ngrams for Compound Words »</a>
</span>
</div>
</div>

                  <!-- end body -->
                </div>
                <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                  <div id="rtpcontainer" style="display: block;">
                    <div class="mktg-promo">
                      <h3>Most Popular</h3>
                      <ul class="icons">
                        <li class="icon-elasticsearch-white"><a href="https://www.elastic.co/webinars/getting-started-elasticsearch?baymax=default&amp;elektra=docs&amp;storm=top-video">Get Started with Elasticsearch: Video</a></li>
                        <li class="icon-kibana-white"><a href="https://www.elastic.co/webinars/getting-started-kibana?baymax=default&amp;elektra=docs&amp;storm=top-video">Intro to Kibana: Video</a></li>
                        <li class="icon-logstash-white"><a href="https://www.elastic.co/webinars/introduction-elk-stack?baymax=default&amp;elektra=docs&amp;storm=top-video">ELK for Logs &amp; Metrics: Video</a></li>
                      </ul>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </section>

        </div>


<div id="elastic-footer"></div>
<script src="https://www.elastic.co/elastic-footer.js"></script>
<!-- Footer Section end-->

      </section>
    </div>

<script src="/guide/static/jquery.js"></script>
<script type="text/javascript" src="/guide/static/docs.js"></script>
<script type="text/javascript">
  window.initial_state = {}</script>
  </body>
</html>
